-- electricity
-- created by cheny3
-- 电磁场力

return {
    apply = function(prop, baseValue)

        -- 威力prop[3]减少的百分比
        return baseValue - math.modf(baseValue * prop[3] / 1000);
    end,

    -- 触发
    trigger = function(who, prop, base)
        local force = prop[3];

        -- 不能为负
        force = math.max(0, force);

        -- 玩家降低电磁力场效果
        local co = 1000;
        local prop2 = PropM.combine(who, "reduce_electricity", 1);
        if prop2[3] > 0 then
            co = 1000 - prop2[3];
        end

        force = FormulaM.invoke("CALC_BIG_DIVISION", force, co, 1000);

        -- 1%保底
        if force > 0 then
            force = math.max(10, force);
        end

        return math.modf(base * force / 1000);
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local damage = prop[3] / 10;

        -- prop[3]减少的百分比
        desc = string.gsub(desc, "{1}", damage);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};